package app.interceptors;

import app.Const;
import com.jfinal.aop.Interceptor;
import com.jfinal.core.ActionInvocation;
import com.jfinal.core.Controller;

/**
 * <p>
 * .
 * </p>
 *
 * @author Jerry Ou
 * @version 1.0 2014-04-21 22:04
 * @since JDK 1.6
 */
public class MobileWxMemberInterceptor implements Interceptor {

    @Override
    public void intercept(ActionInvocation ai) {
        Controller c = ai.getController();
        /*Subject subject = SecurityUtils.getSubject();
        Session session = subject.getSession();
        if (session.getAttribute(Const.MOBILEWXMEMBER_ATTR) == null) {
            long mid = c.getParaToLong("mid", 0l);
            String wxno = c.getPara("wxno");
            if (mid != 0 || wxno != null) {
                Member member = Member.dao.findById(mid);
                if (member == null) {
                    member = Member.dao.findByWxNo(wxno);
                }
                session.setAttribute(Const.MOBILEWXMEMBER_ATTR, member);
            }
        }*/
        String mid = c.getPara(Const.MEMBER_PARAM);
        String wxno = c.getPara(Const.WX_PARAM);
        //TODO 删除
        c.setAttr(Const.MEMBER_PARAM, mid);
        c.setAttr(Const.WX_PARAM, wxno);
        ai.invoke();

    }

}
